package com.actimize.webapp.action;

import java.io.IOException;
import java.util.List;

import javax.servlet.http.HttpServletRequest;

import com.actimize.model.User;
import com.actimize.model.Account;
import com.actimize.service.AccountManager;
import com.actimize.service.impl.AccountManagerImpl;
import com.opensymphony.xwork2.Preparable;

public class AccountInfo extends BaseAction implements Preparable{

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	private User user;
	private List<Account> accounts;
	private AccountManager accountManager;

	public void prepare() {
		
	}

	public String getGeneralInfo() throws IOException {
		HttpServletRequest request = getRequest();
		System.out.println("1="+request.getRemoteUser());
		
		user = userManager.getUserByUsername(request.getRemoteUser());
		
		accountManager = new AccountManagerImpl();
		
		accounts = accountManager.getAccounts(user.getId());
		System.out.println("*************************************");
		System.out.println("user id="+user.getId());
		for (int i=0; i< accounts.size(); i++)
			System.out.println(accounts.get(i).getName());
		System.out.println("*************************************");
		
		return SUCCESS;
	}

}
